<%@ page import="java.util.List" %>
<%@ page import="camuyen.ltwlibrary.model.Category" %>
<%@ page import="camuyen.ltwlibrary.dao.CategoryDao" %>
<%@ page import="camuyen.ltwlibrary.model.Author" %>
<%@ page import="camuyen.ltwlibrary.dao.AuthorDao" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    List<Category> categories = CategoryDao.getAll();
    List<Author> authors = AuthorDao.getAll();
//    String passwordMessage = (String) session.getAttribute("messagePasswordIsNotMatch");
//    if (passwordMessage == null) {
//        passwordMessage = "";
//    }
//    session.setAttribute("messagePasswordIsNotMatch", null);
%>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>Upload Book</title>
    <jsp:include page="/incl/page.script.jsp" flush="true"/>
    <jsp:include page="/incl/page.bootstrap.jsp" flush="true"/>
    <jsp:include page="/incl/page.css.jsp" flush="true"/>

    <script type="text/javascript">
        $(document).ready(function () {
            // set active navigation item
            $('li#upload').addClass('active');
        });
    </script>
</head>
<body>
<div class="container">
    <div class="row-fluid">
        <div class="col-md-12" style="height: 120px;">
            <jsp:include page="/incl/page.loginform.jsp" flush="true"/>
        </div>
    </div>
    <jsp:include page="/incl/page.navigation.jsp" flush="true"/>
    <div class="row-fluid">
        <div class="col-md-12 panel panel-default">
            <div class= "center-block panel-body" style="width: 50%">
                <form  enctype="multipart/form-data" action="${pageContext.request.contextPath}/UploadServlet" method="post" class="form-horizontal" role="form">
                    <div class="form-group">
                        <label class="col-sm-4 control-label" for="title" >Title</label>
                        <div class="col-sm-8">
                            <input name="title" id="title" class="form-control" type="text" value=""/>
                            <p class="help-block" style="color: #ff0000"></p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label" for="author">Author</label>
                        <div class="col-sm-8">
                            <select id="author" name="author" class="selectpicker" multiple>
                                <% for (Author author : authors) { %>
                                    <option value="<%=author.getAuthorId()%>"><%=author.getAuthorName()%></option>
                                <% } %>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label" for="category">Category</label>
                        <div class="col-sm-8">
                            <select id="category" name="category" class="selectpicker" multiple>
                                <%for (Category cat: categories) { %>
                                <option value="<%=cat.getCategoryId()%>"><%=cat.getCategoryName()%></option>
                                <% } %>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label" for="publishedDate">Published date</label>
                        <div class="col-sm-8">
                            <input id="publishedDate" name="publishedDate" class="datepicker form-control" type="text" value="02-16-2012"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label" for="summary">Summary</label>
                        <div class="col-sm-8">
                            <textarea id="summary" name="summary" class="form-control"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-4 control-label" for="file">File</label>
                        <div class="col-sm-8">
                            <input id="file"  name="file" type="file"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-4"></div>
                        <div class="col-sm-8">
                            <button type="submit" class="btn btn-primary">Submit</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
</body>
</html>